<#include "*/component/CombineFieldTags.ftl"/>
<@Title/>
<@ClassAnnotation>

</@ClassAnnotation>
public class ${clazz.name} extends AbstractSpecification<${entity.entityName}> {

${'\t'}private ${entity.entityName}Repository ${entity.objectName}Repository;

${'\t'}public ${clazz.name}(${entity.entityName}Repository ${entity.objectName}Repository) {
${'\t'}${'\t'}this.${entity.objectName}Repository = ${entity.objectName}Repository;
${'\t'}}

${'\t'}@Override
${'\t'}public boolean isSatisfiedBy(${entity.entityName} ${entity.objectName}) {
<#list entity.fields as field>
    <#if field.column.uniqueKey>

${'\t'}${'\t'}if (<@HyperCombineValue field=field prefix='${entity.objectName}.get' suffix='() != null' separator='||' />) {
${'\t'}${'\t'}${'\t'}${entity.entityName} target = ${entity.objectName}Repository.findBy${field.capitalizeName}(<@HyperCombineValue field=field prefix='${entity.objectName}.get' suffix='()' separator=',' />);
${'\t'}${'\t'}${'\t'}if (target != null&&!${entity.objectName}.equals(target)) {
${'\t'}${'\t'}${'\t'}${'\t'}throw new BaseException("${field.column.comment}已存在");
${'\t'}${'\t'}${'\t'}}
${'\t'}${'\t'}}
    </#if>
</#list>
${'\t'}${'\t'}return true;
${'\t'}}

}
